package servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import pojo.*;

public class ViewCartServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    Logger logger=Logger.getLogger(ViewCartServlet.class);  
    public ViewCartServlet() {
        super();
    
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html);charset=utf-8");
		logger.info(((User)request.getSession().getAttribute("user")).getName()+"cart");
		Map<String, OrderInfo> carts=(Map<String, OrderInfo>)request.getSession().getAttribute("cart");
		if(null==carts)
		{
			request.setAttribute("info", "无商品");
			request.getRequestDispatcher("store").forward(request, response);
			return;
		}
		List<OrderInfo> orders=new ArrayList<>();
		for(String s:carts.keySet())
		{
			orders.add(carts.get(s));
		}
	}

	
}
